Developer Documentation

QuickTime 4 API Documentation

Inside Macintosh: Sound

| Previous | Chapter contents | Chapter top | Section top | Next |

Doubleback Procedures

If you wish to customize the double buffering of sound during a play from disk, you must use the SndPlayDoubleBuffer function and define a doubleback procedure. Doubleback procedures also give you the power to modify sampled-sound data immediately before the Sound Manager plays it.

MyDoubleBackProc

A doubleback procedure has the following syntax:

PROCEDURE MyDoubleBackProc (chan: SndChannelPtr;
                                         exhaustedBuffer: SndDoubleBufferPtr);
chan
A pointer to a sound channel on which a play from disk is executing.
exhaustedBuffer
A pointer to a sound double buffer record

DESCRIPTION

The Sound Manager calls the doubleback procedure associated with a play from disk whenever the Sound Manager has exhausted the buffer. As the doubleback procedure refills the buffer, the Sound Manager plays the other buffer. Your application might also call the doubleback procedure twice to fill both buffers before the initial call to SndPlayDoubleBuffer function.

When your doubleback procedure is called, it must

If your doubleback procedure fills the buffer with the last frames of sound that need to be played, then your procedure should set the dbLastBuffer bit of the dbFlags field of the sound double buffer record.

Your doubleback procedure might fill the buffer with data from any of several sources. For example, the doubleback procedure might compute the data, copy it from elsewhere in RAM, or read it from disk. A doubleback procedure can also read data from disk and then modify the data. This might be useful, for example, if you would like the Sound Manager to be able to play sampled-sound data stored in 16-bit binary offset format. Your doubleback procedure could translate the data to the 8-bit binary offset format that the Sound Manager can read before placing it in the buffer.

SPECIAL CONSIDERATIONS

A doubleback procedure is called at interrupt time. It must not make any calls to the Memory Manager, either directly or indirectly. If your callback procedure needs to access your application's global variables, you must ensure that register A5 contains your application's A5. (You can use one of the two long integers in the dbUserInfo field of the sound double buffer record specified by the exhaustedBuffer parameter to pass that value to your callback procedure.)

ASSEMBLY-LANGUAGE INFORMATION

Because a doubleback procedure is called at interrupt time, it must preserve all registers other than A0-A1 and D0-D2.

SEE ALSO

For an example of how you might use doubleback procedures, see "Using Double Buffers" .


© 1999 Apple Computer, Inc.

| Previous | Chapter contents | Chapter top | Section top | Next |